from woniusales_ui_test_ddt.page.basepage import BasePage
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
class HomePage(BasePage):
    loginout_locator=(By.XPATH,'//a[@href="/woniusales/user/logout"]')
    goods_locator = (By.LINK_TEXT, "批次管理")
    store_locator = (By.LINK_TEXT, "商品入库")
    query_locator = (By.LINK_TEXT, "库存查询")
    customer_locator = (By.LINK_TEXT, "会员管理")
    report_locator = (By.LINK_TEXT, "销售报表")
    barcode_locator = (By.XPATH, '//*[@id="barcode"]')
    barcode_text = '22222222'
    queryByBarCode_locator = (By.XPATH, '//button[@onclick="queryByBarCode()"]')
    size_locator = (By.XPATH, '//*[@id="goodssizeList"]/option[2]')
    zhekou_locator = (By.XPATH, '//*[@id="goodslist"]/tr/td[6]/input')
    zhekou = '90'
    addnum_locator = (By.XPATH, '//*[@id="goodslist"]/tr/td[8]/button[2]')
    goods_count_locator = (By.XPATH, '//*[@id="totalbuycount"]')
    tempbuyprice_locator = (By.XPATH, '//*[@id="tempbuyprice"]')  # 应收款
    add_newgood_locator = (By.XPATH, '/html/body/div[4]/div[1]/div/div[2]/a[1]')  # 添加新商品
    cleargoods_locator = (By.XPATH, '/html/body/div[4]/div[1]/div/div[2]/a[2]')  # 清空所有


    def get_loginout_text(self):
        """获取页面的注销按钮的文本"""
        return self.get_text(self.loginout_locator)
    def goto_goodspage(self):  # 跳转批次管理
        self.click(self.goods_locator)
    def goto_storepage(self):  # 跳转商品入库
        self.click(self.store_locator)
    def goto_querypage(self):  # 跳转库存查询
        self.click(self.query_locator)
    def goto_customerpage(self):  # 跳转会员管理
        self.click(self.customer_locator)
    def goto_reportpage(self):  # 跳转会员管理
        self.click(self.customer_locator)

    def input_barcode(self):  # 输入条码
        self.input_text(self.barcode_locator,self.barcode_text)
    def click_query_barcode(self):  # 点击确认条码
        self.click(self.queryByBarCode_locator)
    def click_size(self):  # 选择尺码
        self.click(self.size_locator)
    def input_zhekou(self):  # 修改折扣
        self.input_text(self.zhekou,(Keys.CONTROL,'a'))
        self.input_text(self.zhekou, self.zhekou)
        self.input_text(self.zhekou, (Keys.ENTER,))
    def add_num(self):  # 修改商品数量
        self.click(self.addnum_locator)
    def get_goods_count(self):  # 获取商品数量
        return self.get_text(self.goods_count_locator)

    def get_tempbuyprice(self):  # 获取应收款
        self.get_text(self.tempbuyprice_locator)


    def click_newgoods(self):  # 点击添加新商品
        self.click(self.add_newgood_locator)

    def click_clear_goods(self):  # 点击清空
        self.click(self.cleargoods_locator)











